
function plot2StateMats(matOne,matTwo,names,xaxis,figStru,layout,overTitle) 
% function plot2StateMats(matOne,matTwo,names,xaxis,figStru,layout) 
% 
%% plot2StateMats 
%  Given two matrices of state, plot one against the other 
%  in the same subplot 
% 
%% Inputs
%  matOne   [nobs ns]   matrix of states
%  matTwo   [nobs ns]   matrix of states 
%  names   structure with 
%          states. [ns    1]   cell with names 
%          legend.[2     1]   for each matrix 
%
%  xaxis    [nobs  1]   x-axis vector 
%  figStru 
%  layout   [2 1]       vector [rows,cols] per figure 
%           if empty will plot 1 per figure; 
[nobs ns]=size(matOne); 
if nargin < 7 || isempty(layout); 
    flags.onePerPage=true; 
else 
    flags.onePerPage=false;
end
if nargin < 8 || isempty(overTitle)
    flags.noSupTitle=true; 
else 
    flags.noSupTitle=false; 
end 

figVec=zeros(ns,1);
for ii=1:ns;
    if flags.onePerPage==true
        figVec(ii)=figure;
        figStru.flagNoLegend=0;
        figStru.legend=names.legend;
    else
        if ii==1
            figVec(ii)=figure;
        end
        if ii < ns
            figStru.flagNoLegend=1;
        else
            figStru.flagNoLegend=0;
            figStru.legend=names.legend;
        end
        subplot( layout(1), layout(2), ii);
    end
    plot3samp(xaxis,[matOne(:,ii) matTwo(:,ii)],figStru);
    title(char( names.states{ii} ) );
end
if flags.onePerPage==false 
    figVec=figVec(1); 
end 
   
if flags.noSupTitle==false 
    suptitle(char(overTitle),14); 
end 
